package com.jy.adscm.operation.hscrb.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jy.adscm.bean.system.JyUser;
import com.jy.adscm.exception.AdscmSystemException;
import com.jy.adscm.operation.hscrb.bean.LjzzPartsmadeinfo;
import com.jy.adscm.operation.hscrb.mapper.mysql.LjzzPartsmadeinfoMapper;
import com.jy.adscm.operation.hscrb.service.LjzzPartsmadeinfoService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.jy.adscm.system.mapper.mysql.JyUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zyl
 * @since 2018-11-26
 */
@Service
public class LjzzPartsmadeinfoServiceImpl extends ServiceImpl<LjzzPartsmadeinfoMapper, LjzzPartsmadeinfo> implements LjzzPartsmadeinfoService {
     @Autowired
     LjzzPartsmadeinfoMapper ljzzPartsmadeinfoMapper;
     @Autowired
      JyUserMapper  jyUserMapper;
    @Override
    public List<LjzzPartsmadeinfo> selectByTid(String tid) throws AdscmSystemException {
        Wrapper<LjzzPartsmadeinfo> wrapper =new EntityWrapper<>();
        wrapper.eq("TID",tid);
        List<LjzzPartsmadeinfo> ljzzPartsmadeinfos = ljzzPartsmadeinfoMapper.selectList(wrapper);
        for (LjzzPartsmadeinfo ljzzPartsmadeinfo : ljzzPartsmadeinfos) {
             if (ljzzPartsmadeinfo.getPerson()!=null && !"".equals(ljzzPartsmadeinfo.getPerson())){
                 JyUser jyUser = jyUserMapper.selectById(ljzzPartsmadeinfo.getPerson());
                 ljzzPartsmadeinfo.setPersonName(jyUser.getName());
             }
        }
        return ljzzPartsmadeinfos;
    }


}
